/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package client.gui.controls;

import client.controllers.GalgjeController;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JPanel;

/**
 *
 * @author Gunnar Verhulst
 */
public class TekenPaneel extends JPanel{
    private Graphics g;
    
    public void paintComponent(Graphics g){
        super.paintComponent(g);
        this.g = g;
        tekenBackGround();
        int j = GalgjeController.getInstance().getAantalFouteLetters();
        if(j == 1){
            tekenGalgje(g);
            tekenKoord(g);
        }else if(j == 2){
            tekenGalgje(g);
            tekenKoord(g);
            tekenHoofd(g);
        }else if(j == 3){
            tekenGalgje(g);
            tekenKoord(g);
            tekenHoofd(g);
            tekenRomp(g);
        }else if(j == 4){
            tekenGalgje(g);
            tekenKoord(g);
            tekenHoofd(g);
            tekenRomp(g);
            tekenArm1(g);
        }else if(j == 5){
            tekenGalgje(g);
            tekenKoord(g);
            tekenHoofd(g);
            tekenRomp(g);
            tekenArm1(g);
            tekenArm2(g);
        }else if(j == 6){
            tekenGalgje(g);
            tekenKoord(g);
            tekenHoofd(g);
            tekenRomp(g);
            tekenArm1(g);
            tekenArm2(g);
            tekenBeen1(g);
        }else if(j == 7){
            tekenGalgje(g);
            tekenKoord(g);
            tekenHoofd(g);
            tekenRomp(g);
            tekenArm1(g);
            tekenArm2(g);
            tekenBeen1(g);
            tekenBeen2(g);
         }
    }
    
    public void tekenGalgje(Graphics g) {
        //System.out.println(g.getColor());
        g.setColor (Color.BLACK);

        
        g.drawRect(100,500,300,20);
        g.fillRect(100,500,300,20);
        
        g.drawRect(100, 20, 20, 480);
        g.fillRect(100, 20, 20, 480);
        
        g.drawRect(100, 20, 200, 20);
        g.fillRect(100, 20, 200, 20);

    }
    
    public void tekenKoord(Graphics g){
        g.setColor (Color.BLACK);

        
        g.drawRect(300,20,10,100);
        g.fillRect(300,20,10,100);
    }
    
    public void tekenHoofd(Graphics g){
        g.setColor (Color.BLACK);

        
        //g.drawOval(265,120,80,80);
        g.fillOval(265,120,80,80);
    }
    
    public void tekenRomp(Graphics g){
        g.setColor (Color.BLACK);

        
        //g.drawOval(300,200,10,100);
        g.fillOval(255,195,100,160);
    }
    
    public void tekenArm1(Graphics g){
        Graphics2D g2 = (Graphics2D)g;
        g2.setColor (Color.BLACK);
        g2.setStroke(new BasicStroke(15,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
        g2.drawLine(265,230,220,310);
        //g2.drawLine(345,225,390,310);
        g2.setStroke(new BasicStroke());

    }
    public void tekenArm2(Graphics g){
        Graphics2D g2 = (Graphics2D)g;
        g2.setColor (Color.BLACK);
        g2.setStroke(new BasicStroke(15,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
        //g2.drawLine(265,230,220,310);
        g2.drawLine(345,225,390,310);
        g2.setStroke(new BasicStroke());

    }
    
    public void tekenBeen1(Graphics g){
        Graphics2D g2 = (Graphics2D)g;
        g2.setColor (Color.BLACK);
        g2.setStroke(new BasicStroke(17,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
        g2.drawLine(295,350,295,440);
        //g2.drawLine(345,225,390,310);
        g2.setStroke(new BasicStroke());

    }
    
    public void tekenBeen2(Graphics g){
        Graphics2D g2 = (Graphics2D)g;
        g2.setColor (Color.BLACK);
        g2.setStroke(new BasicStroke(17,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
        //g2.drawLine(265,230,220,310);
        g2.drawLine(315,350,315,440);
        g2.setStroke(new BasicStroke());

    }
    
    public void tekenBackGround(){
        //lucht
        g.setColor(Color.BLUE);
        g.fillRect(0,0,this.getWidth(),2*this.getHeight()/3);
        //gras
        g.setColor(Color.GREEN);
        g.fillRect(0,2*this.getHeight()/3,this.getWidth(),this.getHeight());
        
        g.setColor(Color.yellow);
        
        g.drawOval(20,20,80,80);
        g.fillOval(20,20,80,80);
    }
    
}
